<?php
class Application_Form_Grandprix extends Zend_Form
{
	public function init()
	{
		$circuitDAO = new Application_Model_CircuitDAO();
		$circuits = $circuitDAO->findAll();
		$circuitstab = array();
		foreach($circuits as $circuit)
		{
			$circuitstab[$circuit->getCirNum()] = $circuit->getCirNom();
		}
		
		$this->setName('addGrandprix');
		$this->setMethod('post');
		$this->addAttribs(array('class'=>'form'));
        
		$this->addElement(
            'hidden', 'gpnum', array(
        ));
		
		$this->addElement(
            'text', 'gpnom', array(
                'label' => 'Nom du Grand-Prix :',
                'required' => true,
                'filters'    => array('StringTrim')
            ));
 		
       	$this->addElement('select', 'cirnum',
                          array('MultiOptions' => $circuitstab,
                                  'required' => true,
                                  'label' => 'Circuit :')
                          );    
        
        $this->addElement('text', 'gpnbtours', array(
            'label' => 'Nombre de tours :',
            'required' => true,
        	'validators' => array(
                'int'
            )
            ));
            
        $this->addElement('text', 'gpdate', array(
            'label' => 'Date du Grand-Prix :',
        	'rel' => 'datepicker',
            'required' => true,
        	'validators' => array(
                'Date',
            )
            ));
 		
        $this->addElement('textarea', 'gpcommentaire', array(
            'label' => 'Commentaire :',
            'required' => false,
        	'cols' => 30,
        	'rows' => 5
            ));
            
        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Valider'
            ));
	}
}